package org.quipu.dto;

import java.io.Serializable;
import java.util.Collection;
import java.util.HashMap;
import java.util.Map;

public class BookCacheDto implements Serializable {

    private BookDto book;
    private Map<Long, CurrencyDto> currencies = new HashMap<Long, CurrencyDto>();
    private Map<Long, CategoryDto> categories = new HashMap<Long, CategoryDto>();
    private Map<Long, TagDto> tags = new HashMap<Long, TagDto>();

    public BookDto getBook() {
        return book;
    }

    public void setBook(BookDto book) {
        this.book = book;
    }

    public Map<Long, CurrencyDto> getCurrencies() {
        return currencies;
    }

    public void setCurrencies(Map<Long, CurrencyDto> currencies) {
        if(currencies != null) {
            this.currencies = currencies;
        } else {
            this.currencies.clear();
        }
    }

    public void setCurrencies(Collection<CurrencyDto> currencies) {
        this.currencies.clear();
        if(currencies != null) {
            for(CurrencyDto cur: currencies) {
                this.currencies.put(cur.getId(), cur);
            }
        }
    }

    public Map<Long, CategoryDto> getCategories() {
        return categories;
    }

    public void setCategories(Map<Long, CategoryDto> categories) {
        if(categories != null) {
            this.categories = categories;
        } else {
            this.categories.clear();
        }
    }

    public Map<Long, TagDto> getTags() {
        return tags;
    }

    public void setTags(Map<Long, TagDto> tags) {
        if(tags != null) {
            this.tags = tags;
        } else {
            this.tags.clear();
        }
    }
}
